Skip to content

Instantly share code, notes, and snippets.

@leoherzog
leoherzog / Code.gs
Last active May 9, 2024 15:31
Gather All Google Drive Files of a Certain Type and Change Owner
const newOwner = 'blah@example.com';
const fileTypesToTransfer = ['application/vnd.google-apps.form']; // https://developers.google.com/drive/api/guides/mime-types
function changeOwnership() {
console.log('Gathering all files in Drive of type ' + fileTypesToTransfer.join(',') + '...');
let fileIterator = DriveApp.searchFiles(fileTypesToTransfer.map(x => 'mimeType = "' + x + '"').join(' or '));
let files = [];
while (fileIterator.hasNext()) {
@leesharma
leesharma / And.hdl
Created January 19, 2019 19:29
Nand2Tetris Project 1: Logic Gates
/**
* And gate:
* out = 1 if (a == 1 and b == 1)
* 0 otherwise
*/
CHIP And {
IN a, b;
OUT out;
@leoherzog
leoherzog / voicewatch.py
Last active May 9, 2024 15:31
Python Discord Bot to post to a text channel when people join or leave a voice channel
#!/usr/bin/python3
import discord
import random
intents = discord.Intents.default()
intents.voice_states = True
client = discord.Client(intents=intents)
join_phrases = ['👋 **{0}** joined **{1}**', '🙋 Hi **{0}**! Welcome to **{1}**', '😊 Welcome to **{1}**, **{0}**!', '🤩 EVERYONE SHUT UP! **{0}** is in **{1}** now.']
@leoherzog
leoherzog / code.gs
Created September 19, 2023 18:33
Google Doc Change Notifier
/**
* 1. Go to script.google.com, and when logged in as the user that you want to do the "checking", click "➕ New Project" in the top right
* 2. Copy/Paste all of this code into your new project, and give it a name (e.g. Google Doc Change Notifier)
* 3. Change the `const docs = []` line to include all of the Docs you want to check. For example, `const docs = ["https://docs.google.com/document/blah", "https://docs.google.com/document/foo"];
* 4. Click "▷ Run" in the toolbar and authorize the script to run.
* 5. You're done!
*/
const docs = ["https://docs.google.com/document/d/1Gwt56BiconMLg_u-hdo0asdff27U7DlqLOzHVVgNnoM/edit"];
@beginor
beginor / snowflake-id.sql
Last active May 9, 2024 15:28
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@chrisdone
chrisdone / typing.md
Last active May 9, 2024 15:27
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@bureyburey
bureyburey / split-async-storage
Last active May 9, 2024 15:24
SplitAsyncStorage
/**
* custom wrapper for AsyncStorage that splits the data of a given storageKey to smaller chunks
* a large object with multiple keys will be spreaded to all the keys in the first level of the main object
* { data: { key1: value1, key2: value2, ...} }
* will be saved as key1 => value1, key2 => value2, ...
* this approach is intended to prevent the limitation of 2MB per value of AsyncStorage by spreading the values across the storage
*
* basic usage:
*
* import AsyncStorage from '@react-native-community/async-storage';

MIFARE Classic

Here are the steps to follow in order to read your cards. Your goal is to find as many keys as possible. The keys unlock sections of your card for the Flipper to read them - you must have a card. Once you read enough sections, you can use an emulated or cloned card at the original card reader to unlock it (sometimes even without finding all of the keys!).

Reading the card

Steps:

  1. Dictionary attack: Try to scan your MIFARE Classic card with NFC -> Read. It will try a dictionary attack of default keys to unlock your card, as well as any keys you may have found through other methods. Do not interrupt the dictionary attack, it may take a while! If it finds 32/32 keys (or 80/80) with 16/16 sectors (or 40/40), congratulations and proceed to "Emulation". If not, continue to step 2.
  2. Mfkey32 attack (): If you have only a few keys found or no keys found, you can get mor
@hamelsmu
hamelsmu / webhook-circleback.py
Created April 25, 2024 04:59
Generate a project proposal automatically from a meeting transcript
from fastapi import Request, HTTPException
from pydantic import BaseModel, BaseModel, HttpUrl
from modal import Secret, App, web_endpoint, Image
from typing import Optional, List
from example import proposal
import os
app = App(name="circleback", image=Image.debian_slim().pip_install("openai", "pydantic", "fastapi"))
class Attendee(BaseModel):
@pknowledge
pknowledge / docker-compose.yaml
Created February 26, 2024 16:36
Run Microsoft Azure SQL Edge using docker compose
version: '3.8'
services:
sql:
image: mcr.microsoft.com/azure-sql-edge
container_name: sql
ports:
- "1433:1433"
environment:
ACCEPT_EULA: "1"